#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
ll n,m,a,b,x,z,p,y,c,d;
cin>>p;
string S;
for(ll t=0;t<p;t++){
cin>>n;
vector<ll> vect;
int arr[n];
map<ll,ll> mp1;
ll s=0;
for(ll k=0;k<n;k++){
cin>>a;
vect.push_back(a);
s+=a;
mp1[a]++;
arr[k]=a;
}
m=vect.size();
sort(vect.begin(),vect.end());
mp1.clear();
map<ll,ll> mp;
y=0;
for(ll k=0;k<m;k++) {mp1[vect[k]]=2*k-m+1;mp[vect[k]]=y;y+=vect[k];}
vector<ll> ans;
for(ll k=0;k<n;k++){
//cout<<arr[k]<<" "<<mp1[arr[k]]<<" "<<s-arr[k]<<" "<<mp[arr[k]]<<endl;
ans.push_back(mp1[arr[k]]*arr[k]+s-arr[k]-2*mp[arr[k]]+n);
cout<<ans[k]<<" ";
}
cout<<endl;
}
}
1538A - Stone Game | 1454C - Sequence Transformation |
165B - Burning Midnight Oil | 17A - Noldbach problem |
1350A - Orac and Factors | 1373A - Donut Shops |
26A - Almost Prime | 1656E - Equal Tree Sums |
1656B - Subtract Operation | 1656A - Good Pairs |
1367A - Short Substrings | 87A - Trains |
664A - Complicated GCD | 1635D - Infinite Set |
1462A - Favorite Sequence | 1445B - Elimination |
1656C - Make Equal With Mod | 567A - Lineland Mail |
1553A - Digits Sum | 1359B - New Theatre Square |
766A - Mahmoud and Longest Uncommon Subsequence | 701B - Cells Not Under Attack |
702A - Maximum Increase | 1656D - K-good |
1426A - Floor Number | 876A - Trip For Meal |
1326B - Maximums | 1635C - Differential Sorting |
961A - Tetris | 1635B - Avoid Local Maximums |